from sqlalchemy import *
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

import tparser
import tparser.model
from tparser.model.trip_plan import *
from tparser.model.origin_destination_study import *

class Base(object):

    def __init__(self, options):
        self.db = create_engine(options.db)
        self.db.echo = False
        metadata = MetaData(self.db)
        tparser.model.init(options)
        if options.create:
            tparser.model.DeclarativeBase.metadata.drop_all(bind=self.db)
            tparser.model.DeclarativeBase.metadata.create_all(bind=self.db)

#        self.tpTable  = TripPlan.__table__
#        self.tlegTable = TransitLeg.__table__
#        self.tables = [self.tpTable, self.tlegTable]

    def get_session(self):

        session = Session()
        return session
